package com.lovo.testjpa.service.impl;

import com.lovo.testjpa.bean.Classz;
import com.lovo.testjpa.dao.ClassDAO;
import com.lovo.testjpa.dao.StudentDAO;
import com.lovo.testjpa.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ClassServiceImpl implements ClassService {
    @Autowired
    private ClassDAO classDAO;
    @Autowired
    private StudentDAO studentDAO;
    @Override
    public List<Classz> listClass() {
        return classDAO.findAll();

    }

    @Override
    @Transactional
    public void delete(Integer id) {
        studentDAO.updateByClassId(id);
        classDAO.deleteById(id);
    }
}
